package cate.common.table.ins;


import cate.common.annotation.SplitParse;
import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.util.SplitParser;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@NoteClass("一方实例")
public class InstanceSideRow extends ERow {

    @NoteField("英雄阵容")
    private String heroParamCode;

    @NoteField("主角快照实例ID")
    public int msInsId;

    @NoteField("阵型ID")
    public int positionTid;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("id", -1);
        this.msInsId = xrw.getInteger("主角快照实例ID", 1);
        this.heroParamCode = xrw.getString("英雄阵容");
        this.positionTid = xrw.getInteger("阵型ID", 0);
    }


    @NoteField("英雄阵容")
    public List<HeroParam> heroParamList;

    public static final class HeroParam {

        @SplitParse(order = 0)
        public int insTid;

        @SplitParse(order = 1, defaultValue = "1")
        public byte pos;
    }

    @Override
    public void decode() {
        if (!StringUtils.isBlank(this.heroParamCode)) {
            this.heroParamList = SplitParser.parse(HeroParam.class, this.heroParamCode);
        }

    }
}
